logo头像
Snippet 博客主题

android Flutter 4.组件与布局

本文于375天之前发表,文中内容可能已经过时。

android Flutter 4.组件与布局

Flutter带有一套强大的基本小组件
1 Text 文本
2 Row 水平布局
3 Column 垂直布局
Row Column 其设计基于网络的Flexbox布局模型。
4 Stack 可以让你在绘制顺序上堆叠小部件

然后,您可以Positioned 在a的子项上使用该 小部件, Stack以相对于堆栈的顶部,右侧,底部或左侧边缘定位它们。堆栈基于Web的绝对定位布局模型。

6 Container:Container 小部件可让您创建矩形视觉元素。一个容器可以装饰一个 BoxDecoration,如背景,边框或阴影。A Container 也可以具有边距,填充和应用于其大小的约束。另外, Container 可以使用矩阵在三维空间中对a进行变换。

Using Material Components

质应用程序以MaterialApp 小部件开始, 小部件在应用程序的根部创建了许多有用的小部件,其中包括一个 Navigator管理由字符串标识的一堆小部件(也称为“路由”)的小部件。将 Navigator 让您应用程序的屏幕之间的平稳过渡。使用 MaterialApp 小部件完全是可选的,但是一个很好的做法。

ListView

1 水平ListView

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

@override
Widget build(BuildContext context) {
return new Scaffold(
// appBar: new AppBar(title: new Text("Secutity"),),
body: new Container(
margin: new EdgeInsets.symmetric(vertical: 20.0),
height: 200.0,
child: new ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
new Container(
width: 160.0,
color: Colors.red,
),
new Container(
width: 160.0,
color: Colors.yellow,
),
new Container(
width: 160.0,
color: Colors.green,
),
new Container(
width: 160.0,
color: Colors.yellow,
),
new Container(
width: 160.0,
color: Colors.orange,
),

],
),
)
);
}

支付宝打赏 微信打赏

打赏